#include "portdialog.h"
#include "ui_portdialog.h"
#include <QMessageBox>
#include <QDebug>
#define cout qDebug()  << "[" <<  __FILE__ << ":" <<  __LINE__ << "]"

PortDialog::PortDialog(QWidget *parent) :
    QDialog(parent),
    ui(new Ui::PortDialog)
{
    ui->setupUi(this);

    InitData();
}

void PortDialog::InitData()
{
    ui->PortLEdit->setText(QString("10012"));
    m_sPort = 0;
}

QString PortDialog::GetPort()
{
    return m_sPort;
}

PortDialog::~PortDialog()
{
    delete ui;
}

void PortDialog::on_buttonBox_clicked(QAbstractButton *button)
{
    if(button->text() == "OK")
    {
        m_sPort = ui->PortLEdit->text();
        if(m_sPort.isEmpty())
        {
            QMessageBox::warning(this,"错误","端口不能为空");
        }
    }
    else
    {
        m_sPort = 0;
    }
}

